package com.training.ui;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import com.training.Service.EmployeeService;
import com.training.dto.EmployeeDTO;

@ManagedBean(name = "employeeBean")
@SessionScoped
public class EmployeeBean {

	EmployeeDTO employeeDTO;

	@ManagedProperty(value = "#{employeeService}")
	EmployeeService employeeService;

	public EmployeeService getEmployeeService() {
		return employeeService;
	}

	public void setEmployeeService(EmployeeService employeeService) {
		this.employeeService = employeeService;
	}

	private String userName;
	private String password;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String validateUser() {

		employeeDTO = employeeService.validateEmployee(userName.trim(),
				password.trim());

		if (employeeDTO != null) {

			return "showUser";

		} else {
			return null;
		}
	}

}
